<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:a4j="http://richfaces.org/a4j">

<ui:composition template="../templates/popup.xhtml">
	<ui:define name="titre">#{lbl['menu.hub.departure']}</ui:define>
	<ui:define name="popup_page">

		<!-- Fonction javascript pour la demande de rafraichissement du hub. -->
		<script language="javascript">
			function javascriptOnLoad(){
					self.opener.refreshHub();
				}
		</script>

		<h:form id="formation_2_plan_form">
			<h:panelGrid id="formation_2_plan_panel">
				<h:panelGroup>
					<h:outputText value="#{lbl['compo.departure.plan.title']}" /> : 
			 		<h:outputText value="#{hubManaged.currentSillon.tcmsTrainId}" />
					<p />
				</h:panelGroup>

				<rich:extendedDataTable id="formation_plan_table"
					style="width:1390px;height:560px;border:none;"
					rowClasses="rich_datagrid_even_line, rich_datagrid_odd_line"
					value="#{hubManaged.lstCompositions}" var="composition"
					iterationStatusVar="it">

					<f:facet name="noData">
						<h:outputText value="#{msg['msg.info.nodata']}" />
					</f:facet>

					<rich:column width="50px" style="text-align:center;">
						<f:facet name="header">
							<h:outputText value="#{lbl['compo.rail']}" />
						</f:facet>

						<h:panelGrid id="nv_#{composition.id}" columnClasses="_center"
							width="60px" border="0" cellpadding="0" cellspacing="0"
							style="background-color:#{composition.destinationHexColor};"
							styleClass="rich_datagrid_pos_line"
							rendered="#{composition.destinationTypeBundleId==2}">
							<h:outputText value="#{composition.railNumber}" />
						</h:panelGrid>

						<h:outputText value="#{composition.railNumber}"
							rendered="#{composition.destinationTypeBundleId ne 2}" />
					</rich:column>

					<rich:column width="100px" style="text-align:left;">
						<f:facet name="header">
							<h:outputText value="#{lbl['compo.destination.label']}" />
						</f:facet>
						<h:outputText value="#{composition.destinationLabel}" />
					</rich:column>

					<rich:column width="40px" style="text-align:center;">
						<f:facet name="header">
							<h:outputText value="#{lbl['compo.departure.lot']}" />
						</f:facet>
						<h:outputText value="#{composition.wagon.numLot}" />
					</rich:column>

					<rich:column width="70px" style="text-align:center;">
						<f:facet name="header">
							<h:outputText value="#{lbl['sillon.formation.rail']}" />
						</f:facet>
						<h:outputText
							value="#{hubManaged.currentSillon.railFormationExtId}" />
					</rich:column>

					<rich:column width="55px" style="text-align:center;">
						<f:facet name="header">
							<h:outputText value="#{lbl['common.position']}" />
						</f:facet>
						<h:outputText value="#{composition.wagon.currentPos.posNum+1}" />
					</rich:column>

					<rich:column width="110px" style="text-align:center;">
						<f:facet name="header">
							<h:outputText value="#{lbl['compo.wagon']}" />
						</f:facet>
						<h:outputText value="#{composition.wagon.extId}">
							<f:converter converterId="extIdWagonConverter" />
						</h:outputText>
					</rich:column>

					<rich:column width="80px" style="text-align:right;">
						<f:facet name="header">
							<h:outputText value="#{lbl['common.wagon.length']}" />
						</f:facet>
						<h:outputText value="#{composition.wagon.type.totalLength}"
							rendered="#{composition.wagon.type.totalLength > 0}">
							<f:converter converterId="floatConverter" />
						</h:outputText>
						<h:outputText value="#{lbl['common.nc']}"
							rendered="#{composition.wagon.type.totalLength == 0}" />
					</rich:column>

					<rich:column width="80px" style="text-align:right;">
						<f:facet name="header">
							<h:outputText value="#{lbl['common.wagon.curbweight']}" />
						</f:facet>
						<h:outputText value="#{composition.wagon.type.curbWeight}"
							rendered="#{composition.wagon.type.curbWeight > 0}">
							<f:converter converterId="floatConverter" />
						</h:outputText>
						<h:outputText value="#{lbl['common.nc']}"
							rendered="#{composition.wagon.type.curbWeight == 0}" />
					</rich:column>

					<rich:column width="100px" style="text-align:right;">
						<f:facet name="header">
							<h:outputText value="#{lbl['common.wagon.weight']}" />
						</f:facet>

						<!-- Wagons non vides. -->
						<h:outputText value="#{composition.wagon.weightLading}"
							rendered="#{composition.wagon.weightLading > 0}">
							<f:converter converterId="floatConverter" />
						</h:outputText>

						<!-- Wagons vides. -->
						<h:outputText value="0,00"
							rendered="#{composition.wagon.lading == 'Vide'}" />

						<!-- Wagons non vides à 0. -->
						<h:outputText value="#{lbl['common.nc']}"
							rendered="#{composition.wagon.weightLading == 0 
							and composition.wagon.lading ne 'Vide'}" />
					</rich:column>


					<rich:column width="80px" style="text-align:right;">
						<f:facet name="header">
							<h:outputText value="#{lbl['common.wagon.total.weight']}" />
						</f:facet>

						<!-- Wagons non vides ou vides. -->
						<h:outputText
							value="#{composition.wagon.weightLading + composition.wagon.type.curbWeight}"
							rendered="#{composition.wagon.weightLading > 0 || composition.wagon.lading == 'Vide'}">
							<f:converter converterId="floatConverter" />
						</h:outputText>

						<!-- Wagons non vides à 0. -->
						<h:outputText value="#{lbl['common.nc']}"
							rendered="#{composition.wagon.weightLading == 0 
							and composition.wagon.lading ne 'Vide'}" />
					</rich:column>

					<rich:column width="100px" style="text-align:right;">
						<f:facet name="header">
							<h:outputText value="#{lbl['common.wagon.brake.force']}" />
						</f:facet>
						<h:outputText value="#{composition.wagon.brakeForce}"
							rendered="#{composition.wagon.brakeForce > 0}">
							<f:converter converterId="floatConverter" />
						</h:outputText>
						<h:outputText value="#{lbl['common.nc']}"
							rendered="#{composition.wagon.brakeForce == 0}" />
					</rich:column>

					<rich:column width="513px" style="text-align:left;">
						<f:facet name="header">
							<h:outputText value="#{lbl['common.comment']}" />
						</f:facet>
						<rich:inplaceInput id="comment"
							value="#{composition.wagon.comment}" showControls="false"
							inputWidth="255" />
					</rich:column>
				</rich:extendedDataTable>

				<!-- Le panneau pour les boutons. -->
				<h:panelGrid columns="2" id="formation_plan_2_command_panel"
					columnClasses="_left,_right" style="width:100%">
					<a4j:commandButton value="#{lbl['common.button.cancel']}"
						action="#{hubManaged.refreshHub}">
						<a4j:param name="fromOutcome" value="departure_success"
							assignTo="#{hubManaged.criterion.fromOutCome}" />
					</a4j:commandButton>

					<a4j:commandButton value="#{lbl['common.button.validate']}"
						action="#{hubManaged.processFormationPlan}" />
				</h:panelGrid>
			</h:panelGrid>
		</h:form>
	</ui:define>
</ui:composition>
</html>